package com.shelpe.services.sinbad.entity.jpa.vo;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.shelpe.services.sinbad.service.simbaproxy.SimbaProxyBaseDto;

import lombok.Data;

@Data
@JsonInclude(Include.NON_NULL)
public class AdgroupTargetingDtoVo {
	@JsonProperty("adgroup_targeting_tags")
	private List<AdgroupTargetingTags> targetingTags;

	private SimbaProxyBaseDto.Error error;

	public void addTags(AdgroupTargetingTags targetingTag) {
		if (this.targetingTags == null) {
			this.targetingTags = new ArrayList<AdgroupTargetingTags>();
		}
		this.targetingTags.add(targetingTag);
	}

	@Data
	public static class AdgroupTargetingTags {
		@JsonProperty("crowdDTO")
		private CrowdDto crowdDtos;
		@JsonProperty("isDefaultPrice")
		private int isDefaultPrice;
		@JsonProperty("discount")
		private int discount; // 溢价范围为[5,300],eg:若折扣为105,那么溢价discount为5
	}

	@Data
	@JsonInclude(Include.NON_NULL)
	public static class CrowdDto {
		@JsonProperty("extParam")
		private ExtParam extParam;
		@JsonProperty("templateId")
		private String templateID;
		@JsonProperty("name")
		private String crowdName;
		@JsonProperty("tagList")
		private List<TagList> tagList;

		public void addTag(TagList tag) {
			if (this.tagList == null) {
				this.tagList = new ArrayList<TagList>();
			}
			this.tagList.add(tag);
		}
	}
	
	@Data
	public static class ExtParam{
		@JsonProperty("firstCat")
		private String firstCat;
	}

	@Data
	public static class TagList {
		@JsonProperty("dimId")
		private String dimID; // 标签所属的维度id
		@JsonProperty("tagId")
		private String tagID; // 标签id
		@JsonProperty("tagName")
		private String tagName; // 维度名称,如性别,年龄
		@JsonProperty("optionGroupId")
		private String optionGroupID; // 维度id,如性别年龄的id

	}
}
